//
//  ICMessageNetworkManager.m
//  ICome
//
//  Created by zhangrongwu on 2016/12/5.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICMessageNetworkManager.h"
#import "ICHeaderFile.h"

@implementation ICMessageNetworkManager
+(instancetype)sharedInstance {
    static ICMessageNetworkManager *manager;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        manager = [[ICMessageNetworkManager alloc] init];
    });
    return manager;
}

- (void)customerChangeStatus:(NSDictionary *)param
                     success:(HttpSuccessCompletionHandle)success
                     failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:@"customer/changeStatus"];
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

//- (void)tdoReadChangeStatus:(NSDictionary *)param
//                    success:(HttpSuccessCompletionHandle)success
//                    failure:(HttpFailureCompletionHandle)failure {
//    NSString *url = [self appendRequestBaseURL:@"imserver/tdoRead"];
//    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
//        success(responseObject);
//    } failure:^(NSError *error) {
//        failure(error);
//    }];
//}

-(void)getFromInfoWithParam:(NSDictionary *)param
                  InfoCache:(RequestCache)cache
                    success:(HttpSuccessCompletionHandle)success
                    failure:(HttpFailureCompletionHandle)failure {
    
    NSString *url = [self appendRequestBaseURL:[NSString stringWithFormat:@"%@#%@",GROUP_FROMINFO, param[@"id"]]];
    NSLog(@"%@", url);
    [ICNetworkHelper POST:url parameters:param responseCache:^(id responseCache) {
        if (cache) {
            cache(responseCache);
        }
    } success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

@end
